<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>百商汇</title>
	<meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0,minimum-scale = 1.0,user-scalable = no,width = device-width">
	<meta name="format-detection" content="telephone=no" />
	<link rel="stylesheet" type="text/css" href="../csses/improveInfor.css">
</head>
<body>
	<div class="improveInfor_title">
		完善/修改个人信息
		<img src="../image/back.png" onclick="goBack()">
	</div>
	<div class="improveInfor_box">
		<div class="logo">
			<span>
				<img >
			</span>
			<p>点击上传头像</p>
		</div>
		<ul>
			<li>
				<span>姓 &nbsp;&nbsp; 名</span>
				<input type="text" placeholder="请输入您的真实姓名" readonly="true" class="realName"></input>
			</li>
			<li>
				<span>性 &nbsp;&nbsp; 别</span>
				<div class="gender">
					<div class="M">
						<span class="outside">
							<span class="inside"></span>
						</span>
						<p>男</p>
					</div>
					<div class="F">
						<span class="outside">
							<span class="inside"></span>
						</span>
						<p>女</p>
					</div>
				</div>
			</li>
			<li>
				<span>地 &nbsp;&nbsp; 址</span>
				<input type="text" placeholder="请输入您的地址" class="address" readonly="true"></input>
			</li>
		</ul>
		<div class="submitBtn">提交</div>

		<div class="hiddenBox" style="display: none;">请在APP中完善个人信息</div>
	</div>


	<script type="text/javascript" src="../lib/flexible.js"></script>
	<script type="text/javascript" src="../lib/jquery-1.10.1.min.js"></script>
	<script type="text/javascript">
		onload = function(){
			$('.hiddenBox').css('display','block');
			setTimeout(function(){
				$('.hiddenBox').css('display','none');
			},1500);
		}

		$.ajax({
			type : 'post',
			url : '/api/v1/user/getUserInfo',
			data : {
				paramStr: "{'userName':'" + sessionStorage.userName +  "','token':'" + sessionStorage.token + "'}"
			},
			dataType : 'json',
			timeout : 10000,
			success : function (data) {
				if(data.code == 200){
					var obj = JSON.parse(data.data);
					$('.realName').attr('value',obj.realName);
					$('.logo img').attr('src',obj.headImg);
					if(obj.sex == 'F'){
						$('.F .inside').css('display','block');
					}else{
						$('.M .inside').css('display','block');
					}
					$('.address').attr('value',obj.address);
				}
			},
			error : function (xhr,type,errorThrown) {

			}
		});


		$('.submitBtn').click(function(){
			$('.hiddenBox').css('display','block');
			setTimeout(function(){
				$('.hiddenBox').css('display','none');
			},1500);
			// var $realName = $('.realName').val();
			// var $sex;
			// if($('.M .inside').css('display') == 'block'){
			// 	$sex = 'M';
			// }else{
			// 	$sex = 'F';
			// }
			// var $address = $('.address').val();

			// if(!$realName || !$sex || !$address){
			// 	remind('请填写完整的信息');
			// }else{
			// 	$.ajax({
			// 		type : 'post',
			// 		url : '/api/v1/user/changeUserInfo',
			// 		data : {
			// 			paramStr: "{'userName':'" + sessionStorage.userName +  "','token':'" + sessionStorage.token + "','sex':'" + $sex +"','address':'" + $address +"','realName':'" + $realName +"'}"
			// 		},
			// 		dataType : 'json',
			// 		timeout : 10000,
			// 		success : function (data) {
			// 			remind(data.message);
			// 		},
			// 		error : function (xhr,type,errorThrown) {
			// 			alert('未知错误');
			// 		}
			// 	});
			// }
		});


		// onload = function () {
		// 	var tab = new Tab('inside','outside');
		// 	tab.init();
		// };

		// function Tab (classname1,classname2) {
		// 	this.aIn = document.getElementsByClassName(classname1);
		// 	this.aOut = document.getElementsByClassName(classname2);
		// }

		// Tab.prototype.init = function () {
		// 	that = this;
		// 	for(var i = 0; i < this.aOut.length; i++){
		// 		this.aOut[i].index = i;
		// 		this.aOut[i].onclick = function () {
		// 			that.change(this);
		// 			var m = event.target.parentNode;
		// 			var n = m.getAttribute('class');
		// 			console.log(n);
		// 		}
		// 	}
		// };

		// Tab.prototype.change = function (obj) {
		// 	for(var i = 0; i < this.aOut.length; i++){
		// 		this.aIn[i].style.display = 'none';
		// 	}
		// 	this.aIn[obj.index].style.display = 'block';
		// };
		function goBack(){
			window.history.back();
		}
	</script>
</body>
</html>